/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.una.pol.ii.is2.domain.flota;

import py.una.pol.ii.is2.domain.taller.OrdenMantenimiento;
import py.una.pol.ii.is2.domain.registro.RegistroUtilizacion;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "vehiculo")
@NamedQueries({@NamedQuery(name = "Vehiculo.findAll", query = "SELECT v FROM Vehiculo v"), @NamedQuery(name = "Vehiculo.findByVehiCod", query = "SELECT v FROM Vehiculo v WHERE v.vehiCod = :vehiCod"), @NamedQuery(name = "Vehiculo.findByVehiUbicacion", query = "SELECT v FROM Vehiculo v WHERE v.vehiUbicacion = :vehiUbicacion"), @NamedQuery(name = "Vehiculo.findByVehiKilometraje", query = "SELECT v FROM Vehiculo v WHERE v.vehiKilometraje = :vehiKilometraje"), @NamedQuery(name = "Vehiculo.findByVehiNroChapa", query = "SELECT v FROM Vehiculo v WHERE v.vehiNroChapa = :vehiNroChapa"), @NamedQuery(name = "Vehiculo.findByVehiEstado", query = "SELECT v FROM Vehiculo v WHERE v.vehiEstado = :vehiEstado"), @NamedQuery(name="Vehiculo.findByVehiNroMovil", query = "SELECT v FROM Vehiculo v WHERE v.vehiNroMovil = :vehiNroMovil")})
public class Vehiculo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="vehiculo_generator")
    @SequenceGenerator(name="vehiculo_generator", sequenceName="vehiculo_vehi_cod_seq", allocationSize=1)
    @Basic(optional = false)
    @Column(name = "vehi_cod")
    private Integer vehiCod;
    @Basic(optional = false)
    @Column(name = "vehi_ubicacion")
    private int vehiUbicacion; 
    @Column(name = "vehi_kilometraje")
    private Long vehiKilometraje;
    @Column(name = "vehi_nro_chapa")
    private String vehiNroChapa;
    @Column(name = "vehi_nromovil")
    private String vehiNroMovil;

    public String getVehiNroMovil() {
        return vehiNroMovil;
    }

    public void setVehiNroMovil(String vehiNroMovil) {
        this.vehiNroMovil = vehiNroMovil;
    }
    @Column(name = "vehi_estado")
    private Integer vehiEstado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "reutCodVehiculo")
    private Collection<RegistroUtilizacion> registroUtilizacionCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ormaCodVehiculo")
    private Collection<OrdenMantenimiento> ordenMantenimientoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vehiculo")
    private Collection<VehiculoPlantilla> vehiculoPlantillaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vehiculo")
    private Collection<VehiculoCaracteristica> vehiculoCaracteristicaCollection;
    @JoinColumns({@JoinColumn(name = "vehi_cod_modelo", referencedColumnName = "mamo_cod_modelo"), @JoinColumn(name = "vehi_cod_marca", referencedColumnName = "mamo_cod_marca")})
    @ManyToOne(optional = false)
    private MarcaModelo marcaModelo;
    @JoinColumn(name = "vehi_cod_tipo", referencedColumnName = "tipo_cod")
    @ManyToOne(optional = false)
    private Tipo vehiCodTipo;

    public Vehiculo() {
    }

    public Vehiculo(Integer vehiCod) {
        this.vehiCod = vehiCod;
    }

    public Vehiculo(Integer vehiCod, int vehiUbicacion) {
        this.vehiCod = vehiCod;
        this.vehiUbicacion = vehiUbicacion;
    }

    public Integer getVehiCod() {
        return vehiCod;
    }

    public void setVehiCod(Integer vehiCod) {
        this.vehiCod = vehiCod;
    }

    public int getVehiUbicacion() {
        return vehiUbicacion;
    }

    public void setVehiUbicacion(int vehiUbicacion) {
        this.vehiUbicacion = vehiUbicacion;
    }

    public Long getVehiKilometraje() {
        return vehiKilometraje;
    }

    public void setVehiKilometraje(Long vehiKilometraje) {
        this.vehiKilometraje = vehiKilometraje;
    }

    public String getVehiNroChapa() {
        return vehiNroChapa;
    }

    public void setVehiNroChapa(String vehiNroChapa) {
        this.vehiNroChapa = vehiNroChapa;
    }

    public Integer getVehiEstado() {
        return vehiEstado;
    }

    public void setVehiEstado(Integer vehiEstado) {
        this.vehiEstado = vehiEstado;
    }

    public Collection<RegistroUtilizacion> getRegistroUtilizacionCollection() {
        return registroUtilizacionCollection;
    }

    public void setRegistroUtilizacionCollection(Collection<RegistroUtilizacion> registroUtilizacionCollection) {
        this.registroUtilizacionCollection = registroUtilizacionCollection;
    }

    public Collection<OrdenMantenimiento> getOrdenMantenimientoCollection() {
        return ordenMantenimientoCollection;
    }

    public void setOrdenMantenimientoCollection(Collection<OrdenMantenimiento> ordenMantenimientoCollection) {
        this.ordenMantenimientoCollection = ordenMantenimientoCollection;
    }

    public Collection<VehiculoPlantilla> getVehiculoPlantillaCollection() {
        return vehiculoPlantillaCollection;
    }

    public void setVehiculoPlantillaCollection(Collection<VehiculoPlantilla> vehiculoPlantillaCollection) {
        this.vehiculoPlantillaCollection = vehiculoPlantillaCollection;
    }

    public Collection<VehiculoCaracteristica> getVehiculoCaracteristicaCollection() {
        return vehiculoCaracteristicaCollection;
    }

    public void setVehiculoCaracteristicaCollection(Collection<VehiculoCaracteristica> vehiculoCaracteristicaCollection) {
        this.vehiculoCaracteristicaCollection = vehiculoCaracteristicaCollection;
    }

    public MarcaModelo getMarcaModelo() {
        return marcaModelo;
    }

    public void setMarcaModelo(MarcaModelo marcaModelo) {
        this.marcaModelo = marcaModelo;
    }

    public Tipo getVehiCodTipo() {
        return vehiCodTipo;
    }

    public void setVehiCodTipo(Tipo vehiCodTipo) {
        this.vehiCodTipo = vehiCodTipo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vehiCod != null ? vehiCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vehiculo)) {
            return false;
        }
        Vehiculo other = (Vehiculo) object;
        if ((this.vehiCod == null && other.vehiCod != null) || (this.vehiCod != null && !this.vehiCod.equals(other.vehiCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.ii.is2.dao.flota.Vehiculo[vehiCod=" + vehiCod + "]";
    }

}
